#include <glib.h>
#include <stdio.h>
#include "common.h"

int main(int argc,char *argv[])
{
	GString *str;
	GString *tmp;
	gchar *r;
	str = g_string_new(NULL);
	printf("str[%p]: data[%s] len[%ld] alen[%ld]\n", str, str->str, str->len, str->allocated_len);
	tmp = g_string_append(str, ", My name is Jake, Hleow123131052047lasdjfoiasdfnlbjhawoilrj23rjfsd;afjkfkjasdlfjoialfjslfjljlkljljl");
	printf("tmp[%p]: data[%s] len[%ld] alen[%ld]\n", tmp, tmp->str, tmp->len, tmp->allocated_len);
	printf("str[%p]: data[%s] len[%ld] alen[%ld]\n", str, str->str, str->len, str->allocated_len);

	r = g_string_free(str, TRUE);
	printf("\ntmp[%p]: data[%s] len[%ld] alen[%ld]\n", tmp, tmp->str, tmp->len, tmp->allocated_len);
	printf("str[%p]: data[%s] len[%ld] alen[%ld]\n", str, str->str, str->len, str->allocated_len);
	printf("r[%p]: %s\n", r, r);

	//g_free(str);
	g_free(tmp);
	printf("\ntmp[%p]: data[%s] len[%ld] alen[%ld]\n", tmp, tmp->str, tmp->len, tmp->allocated_len);
	printf("str[%p]: data[%s] len[%ld] alen[%ld]\n", str, str->str, str->len, str->allocated_len);

    return 0;
} 
